// swagger/swagger.js

const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');

// Swagger 配置
const swaggerOptions = {
    definition: {
        openapi: '3.0.0',
        info: {
            title: 'Node.js API',
            version: '1.0.0',
            description: 'A simple API for books management',
        },
        servers: [
            {
                // url: 'http://localhost:3000',
                url: 'http://192.168.106.89:3000',
                // http://192.168.106.89:3000/api-docs
            },
        ],
    },
    apis: ['./routes/*.js'],  // 指定需要生成文档的路由文件路径
};

// 生成 Swagger 文档
const swaggerDocs = swaggerJsdoc(swaggerOptions);

module.exports = {swaggerUi, swaggerDocs};
